#pragma once

#include <nav_msgs/OccupancyGrid.h>
#include <geometry_msgs/Pose2D.h>
#include <geometry_msgs/Polygon.h>

#include <boost/shared_ptr.hpp>
#include <nlohmann/json.hpp>

#include <vector>
#include <string>

class MapMetaData
{    
public:        
    int width;
    int height;
    double resolution;
    geometry_msgs::Pose2D initialPose;
    geometry_msgs::Pose2D chargeStationPose;
    std::vector<geometry_msgs::Polygon> virtualWalls;
};

typedef boost::shared_ptr<MapMetaData> MapMetaDataPtr;

class MapIO {
public:    
    class MapData
    {
    public:
        nav_msgs::OccupancyGrid map;
        geometry_msgs::Pose2D initialPose;
        std::vector<geometry_msgs::Polygon> virtualWalls;
    };
    typedef boost::shared_ptr<MapData> MapDataPtr;

public:
    static MapDataPtr loadMap(const std::string name);
    static std::string getDefaultMapName();
    static MapMetaDataPtr loadMapMetaData(std::string name);
    static void saveMapMetaData(std::string name, MapMetaDataPtr metaData);

    static const double OCCUPIED_THRESH_;
    static const double FREE_THRESH_;
private:
    static std::string mapDirPath_;
};
